<?php

use Faker\Factory as Faker;
use App\Models\ItemContract;
use App\Repositories\ItemContractRepository;

trait MakeItemContractTrait
{
    /**
     * Create fake instance of ItemContract and save it in database
     *
     * @param array $itemContractFields
     * @return ItemContract
     */
    public function makeItemContract($itemContractFields = [])
    {
        /** @var ItemContractRepository $itemContractRepo */
        $itemContractRepo = App::make(ItemContractRepository::class);
        $theme = $this->fakeItemContractData($itemContractFields);
        return $itemContractRepo->create($theme);
    }

    /**
     * Get fake instance of ItemContract
     *
     * @param array $itemContractFields
     * @return ItemContract
     */
    public function fakeItemContract($itemContractFields = [])
    {
        return new ItemContract($this->fakeItemContractData($itemContractFields));
    }

    /**
     * Get fake data of ItemContract
     *
     * @param array $postFields
     * @return array
     */
    public function fakeItemContractData($itemContractFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'item_id' => $fake->randomDigitNotNull,
            'photo' => $fake->word,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $itemContractFields);
    }
}
